﻿
Partial Class Listado
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack() Then

            If Not HttpContext.Current.User.Identity.IsAuthenticated Then
                Response.Redirect(FormsAuthentication.LoginUrl)
            End If

            Call DoCargaSolicitudes("S")

        End If

    End Sub

    Sub DoCargaSolicitudes(ByVal strEstatus As String)
        Dim datosBD = New clsDatos()
        Dim tableTemp = New System.Data.DataTable()
        Dim i As Integer
        Dim fecha1 As Date
        Dim fecha2 As Date

        tableTemp = datosBD.GetDatos("SELECT * FROM Art_Captura where capart_estatus='" & strEstatus & "' order by capart_id desc")
        tableTemp.Columns.Add("dias")

        For i = 0 To tableTemp.Rows.Count - 1
            Select Case tableTemp.Rows(i)("capart_estatus").ToString().Trim()
                Case "S"
                    tableTemp.Rows(i)("capart_estatus") = "SOLICITADO"
                Case "R"
                    tableTemp.Rows(i)("capart_estatus") = "RECHAZADO"
                Case "A"
                    tableTemp.Rows(i)("capart_estatus") = "AUTORIZADO"
            End Select

            fecha1 = Date.Now.ToShortDateString()
            fecha2 = Date.Parse(tableTemp.Rows(i)("capart_fecha"))
            tableTemp.Rows(i)("dias") = Math.Abs(Int((fecha1 - fecha2).TotalDays))
        Next (i)

        grdSolicitudes.DataSource = tableTemp
        grdSolicitudes.DataBind()

    End Sub

    Protected Sub rdSolicitados_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdSolicitados.CheckedChanged
        If rdSolicitados.Checked = True Then
            DoCargaSolicitudes("S")
        End If
    End Sub

    Protected Sub rdAutorizados_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdAutorizados.CheckedChanged
        If rdAutorizados.Checked = True Then
            DoCargaSolicitudes("A")
        End If
    End Sub

    Protected Sub rdRechazados_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdRechazados.CheckedChanged
        If rdRechazados.Checked = True Then
            DoCargaSolicitudes("R")
        End If
    End Sub
End Class
